public static class {{ name.upper_camel_case }} {
  {%- for field in fields %}
  private {{ field.type_info.name }} {{ field.name.lower_camel_case }};
  {%- endfor %}

  {%- for nested_enum in nested_enums %}
  {{ '\n' + indent(nested_enums[nested_enum], 1) }}
  {%- endfor %}

  public {{ name.upper_camel_case }}({%- for field in fields %}{{ field.type_info.name }} {{ field.name.lower_camel_case }}{{ ", " if not loop.last }}{%- endfor %}) {
    {%- for field in fields %}
    this.{{ field.name.lower_camel_case }} = {{ field.name.lower_camel_case }};
    {%- endfor %}
  }

  {%- for field in fields %}
  public {{ field.type_info.name }} get{{ field.name.upper_camel_case }}() {
    return {{ field.name.lower_camel_case }};
  }
  {%- endfor %}

  protected {{ plugin_name.upper_camel_case }}Proto.{{ name.upper_camel_case }} rpc{{ name.upper_camel_case }}() {
    return {{ plugin_name.upper_camel_case }}Proto.{{ name.upper_camel_case }}.newBuilder()
    {%- for field in fields %}
      {%- if field.type_info.is_repeated %}
        {%- if field.type_info.is_primitive %}
      .addAll{{ field.name.upper_camel_case }}({{ field.name.lower_camel_case }})
        {%- else %}
      .addAll{{ field.name.upper_camel_case }}({{ field.name.lower_camel_case }}.stream().map({{ field.type_info.inner_name }}::rpc{{ field.type_info.inner_name }}).collect(Collectors.toList()))
        {%- endif %}
      {%- else %}
        {%- if field.type_info.is_primitive %}
      .set{{ field.name.upper_camel_case }}(this.{{ field.name.lower_camel_case }})
        {%- else %}
      .set{{ field.name.upper_camel_case }}(this.{{ field.name.lower_camel_case }}.rpc{{ field.type_info.inner_name }}())
        {%- endif %}
      {%- endif %}
    {%- endfor %}
      .build();
  }

  protected static {{ name.upper_camel_case }} translateFromRpc({{ plugin_name.upper_camel_case }}Proto.{{ name.upper_camel_case }} rpc{{ name.upper_camel_case }}) {
    return new {{ name.upper_camel_case }}(
            {%- for field in fields %}
            {%- if field.type_info.is_repeated %}
                {%- if field.type_info.is_primitive %}
                rpc{{ name.upper_camel_case }}.get{{ field.name.upper_camel_case }}List(){{ "," if not loop.last }}
                {%- else %}
                rpc{{ name.upper_camel_case }}.get{{ field.name.upper_camel_case }}List().stream().map({{ field.type_info.inner_name }}::translateFromRpc).collect(Collectors.toList()){{ "," if not loop.last }}
                {%- endif %}
            {%- else %}
                {%- if field.type_info.is_primitive %}
            rpc{{ name.upper_camel_case }}.get{{ field.name.upper_camel_case }}(){{ "," if not loop.last }}
                {%- else %}
            {{ field.type_info.name }}.translateFromRpc(rpc{{ name.upper_camel_case }}.get{{ field.name.upper_camel_case }}()){{ "," if not loop.last }}
                {%- endif %}
            {%- endif %}
            {%- endfor %});
  }
}
